<%@ page language="java" contentType="text/html;charset=utf-8" pageEncoding="utf-8" %>
<%@ page import="java.util.*" %>
<%@ page import="com.sms.homework.*" %>

<%	//清除内存
	response.setHeader("Pragma","No-cache"); 
	response.setHeader("Cache-Control","no-cache"); 
	response.setDateHeader("Expires", 0); 
%> 


<%
	request.setCharacterEncoding("utf-8");
	String userno = (String)session.getAttribute("userno");
	
	String row = request.getParameter("id");//获取该项目是第几行的参数(从0开始的)
	int num = Integer.parseInt(row);
	System.out.print(num);
	List<Map> jlist=Homework.getwork(num);
	System.out.print(jlist.size());	
	Homework work= new Homework();
	if(jlist != null && jlist.size() > 0) {
		Map map1=jlist.get(0);
		//得到该项目的对象并赋值
		work.init(map1);
	} else {
		System.out.println("error");
	}
%>	

<body>
<div id="work" style="padding:20px">


<table cellpadding="0" cellspacing="0" width=100% height="100%">
    <tr><td width='10%'><label for="name">作业名称:</label></td><td style="text-align:left;height:30px;"><%= work.getTitle() %></td></tr>
    <tr><td><label for="desc">作业内容:</label></td><td><textarea readonly style="width:100%;overflow:auto;background-color:white;border:0" rows=5><%=work.getContent() %></textarea></td></tr>  
    <tr><td><label for="begintime" style="width:110px;">作业开始时间：</label></td><td style="text-align:left;height:30px;"><%= work.getStartTime() %></td></tr> 
    <tr><td><label for="deadline" style="width:110px;">作业截止时间：</label></td><td style="text-align:left;height:30px;" id="changetime"><%= work.getEndTime() %></td></tr> 
    <tr><td><label for="header">接收者：</label></td><td style="text-align:left;height:30px;" id="changeLeader"><%= work.getName() %></td></tr>
     
     <% 
     	List<Map> appendFile = null;
		//如果有附件
		if(work.getIsAppend().equals("1")) {
			appendFile = new ArrayList<Map>();
			appendFile = work.getAppendFile();
			for(int i=0; i<appendFile.size(); i++) {
			
     %>  
      		<tr class="addfiles"><td><label for="file">附件链接：</label></td>
      		<td style="text-align:left;height:30px;">
      <% 
      		
      				Map<String, String> map = (Map<String, String>)appendFile.get(i);
      				String type=(String)map.get("type");
					String fileName = (String)map.get("fileName");
					String saveName = (String)map.get("saveName");
      %>
      			<a href="DownServlet?fileName=<%= fileName %>&saveName=<%= saveName %>"><%=type+i+":"+fileName %></a>&nbsp;&nbsp;
      <%
      		}
      %>
      
      		</td></tr>
      <% }%> 
      <tr><td id='before'  colspan="2" class="tip" style="text-align:left;"></td></tr>
     <tr>
     <td> 该生提交的作业合格请点击按钮</td>
     <td align="center"><input type="button" id="set" value="该学生已完成"  style="margin-top:10px;" /></td></tr>
</table>
<input type="hidden" id="taskid" value="<%=num %>">
</div>

<script type="text/javascript">
$(document).ready(function(){
$("#set").click(function(){                   
                    var id=$("#taskid").val();
                    //alert(id);
					$.ajax({
						 url:'homework_manage/teacher/change_status.jsp',//项目进度更改处理链接，
						  data:'row='+id ,
						  dataType:'text',
						 success:function(msg){ 
						 	//alert(msg);  
							  if(msg=='ok'){
								  alert('已设置该学生完成作业！');					
								  }
							else {
								alert("设置该学生完成作业失败");
								//alert(msg);
							}
							  }
						 })
					
				
					 


})

})


</script>